home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10982 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: inforamp.net!ts24-15
  2. From: rmorin@inforamp.net (Randy Charles Morin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Truncate binaryfile at a special position
  5. Date: Tue, 12 Mar 96 04:52:02 GMT
  6. Organization: MiddleWorld SoftWare
  7. Message-ID: <4i2vu2$psp@sam.inforamp.net>
  8. References: <314437C0.41C67EA6@theoinf.tu-ilmenau.de>
  9. NNTP-Posting-Host: ts24-15.tor.inforamp.net
  10. X-Newsreader: News Xpress Version 1.0 Beta #4
  11.  
  12. In article <314437C0.41C67EA6@theoinf.tu-ilmenau.de>,
  13.    Gregor Gaertner <gregor.gaertner@theoinf.tu-ilmenau.de> wrote:
  14. >I have the following problem:
  15. >I have a file, where the last 200 bytes are useless. No I want to
  16. >truncate the last 200 bytes, but I don't know how to realize this with
  17. >the help of the streamclasses in C++. The way to copy the part until the
  18. >useless bytes to a new file is not acceptable for me, because if the
  19. >file is 20 Mb long and I want only to cut 200 bytes from the end, I need
  20. >with this insufficient method 20Mb free space more on the harddisc total
  21. >because of the copy. 
  22. >Can anyone help ???
  23.  
  24. Have you tried something like
  25.  
  26. ofstream os(filename);
  27. os.seekp(200, end);
  28. os << endl;
  29.  
  30. or 
  31.  
  32. ofstream os(filename);
  33. os.seekp(200, end);
  34. os.ignore(200);
  35.  
  36. Just a few suggestion, I don't know if they works.
  37. Actually, I doubt the first one words.
  38.  
  39. Agrivar
  40.